<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  -->

<sp-visualization-config-outer
    [configurationValid]="
        currentlyConfiguredWidget.visualizationConfig.configurationValid
    "
>
    <sp-configuration-box title="Field">
        <sp-select-property
            [availableProperties]="fieldProvider.numericFields"
            [selectedProperty]="
                currentlyConfiguredWidget.visualizationConfig
                    .selectedFieldToObserve
            "
            (changeSelectedProperty)="selectFieldToObserve($event)"
        >
        </sp-select-property>
    </sp-configuration-box>

    <sp-configuration-box title="Settings">
        <div fxLayout="column" fxLayoutGap="10px">
            <div
                fxLayout="row"
                fxLayoutGap="10px"
                fxLayoutAlign="start center"
                fxFlex="100"
            >
                <small fxFlex="30">Threshold</small>
                <mat-form-field color="accent" appearance="outline" fxFlex>
                    <input
                        type="text"
                        [(ngModel)]="
                            currentlyConfiguredWidget.visualizationConfig
                                .selectedThreshold
                        "
                        matInput
                        (input)="selectThreshold($event.target.value)"
                        [pattern]="'[0-9.,]*'"
                        (keydown)="restrictInput($event)"
                    />
                </mat-form-field>
            </div>

            <div
                fxLayout="row"
                fxLayoutGap="10px"
                fxLayoutAlign="start center"
                fxFlex="100"
            >
                <small fxFlex="30">With Threshold being</small>
                <mat-radio-group
                    [(ngModel)]="
                        currentlyConfiguredWidget.visualizationConfig
                            .selectedUpperLimit
                    "
                    (change)="selectUpperLimit($event.source.value)"
                >
                    <mat-radio-button [value]="true"
                        >Upper Limit</mat-radio-button
                    >
                    <mat-radio-button [value]="false"
                        >Lower Limit</mat-radio-button
                    >
                </mat-radio-group>
            </div>

            <div
                fxLayout="row"
                fxLayoutGap="10px"
                fxLayoutAlign="start center"
                fxFlex="100"
            >
                <small fxFlex="30">Warning Range (%)</small>
                <mat-form-field color="accent" appearance="outline" fxFlex>
                    <input
                        [(ngModel)]="
                            currentlyConfiguredWidget.visualizationConfig
                                .selectedWarningRange
                        "
                        matInput
                        type="text"
                        (input)="selectWarningRange($event.target.value)"
                        [pattern]="'[0-9.,]*'"
                        (keydown)="restrictInput($event)"
                    />
                    <div
                        *ngIf="warningRangeInterval"
                        class="warning-range-info"
                    >
                        <small>{{ warningRangeInterval }}</small>
                    </div>
                </mat-form-field>
            </div>
            <div
                fxLayout="row"
                fxLayoutGap="10px"
                fxLayoutAlign="start center"
                fxFlex="100"
                class="checkbox-container"
            >
                <small>Show Value in Traffic Light</small>
                <mat-checkbox
                    color="accent"
                    [(ngModel)]="
                        currentlyConfiguredWidget.visualizationConfig
                            .selectedToShowValue
                    "
                    (ngModelChange)="selectToShowValue($event)"
                >
                </mat-checkbox>
            </div>
        </div>
    </sp-configuration-box>
</sp-visualization-config-outer>
